<head>
    <link href="${ctx}/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx}/font-awesome/3.0.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctx}/css/index.css" rel="stylesheet">
    <link href="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.css" rel="stylesheet">
    <script src="${ctx}/jquery/2.1.4/jquery.min.js"></script>
    <script src="${ctx}/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/extensions/export/bootstrap-table-export.min.js"></script>
    <script src="${ctx}/js/extends.js"></script>
    <script src="${ctx}/layui/layui.all.js"></script>
    <script src="${ctx}/js/util.js"></script>
    <link href="${ctx}/layui/css/layui.css" rel="stylesheet">
    <style>
        .btn {
            font-size: 12px;
        }

        .layui-form-checkbox[lay-skin=primary] i {
            top: 5px;
        }
    </style>
</head>
<body>
<title>xianyu -- sdk视频</title>
<div style="padding: 10px 20px">
    <form class="layui-form"style="margin-top: 10px;">
    <div class="layui-inline">
        <label class="layui-form-label" style="width: 120px">起始时间</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="star" placeholder="请选择时间">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label" style="width: 120px">结束时间</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="end" placeholder="请选择时间">
        </div>
    </div>

        <div class="layui-inline">
            <select name="sdkId" id="sdkId" lay-verify="" style="width: 180px">
                <option value="kuaishou">百度看视频</option>
            </select>
        </div>
    </form>
    <button class="layui-btn" onclick="search()" style="float: left;margin-left:20px">
        <i class="layui-icon">&#xe669;</i> 查询
    </button>


    <table class="table table-border table-bordered table-hover table-bg table-sort" id="layTable"
           lay-filter="tableFilter">

    </table>
</div>


</body>
<style>

</style>

<!--请在下方写此页面业务相关的脚本-->


<script type="text/javascript">
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#star'
            , type: 'datetime'
        });
        laydate.render({
            elem: '#end'
            , type: 'datetime'
        });
    });
    layui.use('table', function () {
        tableIns = layui.table,
            form = layui.form;
        tableIns.render({
            elem: '#layTable'
            ,
            totalRow:true
            ,
            url: '/sdk/videolist'
            ,
            method: 'POST'
            ,
            toolbar: true
            ,
            limits: [10,50,500,100]
            ,
            id: 'dataTableId'
            ,
            cols: [[
                 {
                    field: 'createTime',
                    title: '时间',
                    width: 180,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return dateFormat(data.createTime);
                    }
                }
                , {
                    field: 'myMoney',
                    title: '我们的收入',
                    width: 150,
                    align: 'center',
                    sort: true,
                    totalRow:true
                }
                , {
                    field: 'money',
                    title: '用户收入',
                    width: 150,
                    align: 'center',
                    sort: true,
                    totalRow:true
                }
                , {
                    field: 'event',
                    title: '奖励说明',
                    width: 550,
                    align: 'center',
                    sort: true,
                    totalRow:true
                }
                , {
                    field: 'memberId',
                    title: '用户id',
                    width: 150,
                    align: 'center',
                    sort: true
                }
                , {
                    field: 'sdkId',
                    title: 'sdk名称',
                    width: 150,
                    align: 'center',
                    sort: true
                }
                , {
                    field: 'param',
                    title: '请求参数',
                    width: 150,
                    align: 'center',
                    sort: true
                }
                , {
                    field: 'orderNum',
                    title: '订单号',
                    width: 150,
                    align: 'center',
                    sort: true
                }

            ]]
            ,
            page: true
        });
        form.render();
        form.on('switch(sexDemo)', function (obj) {
            // layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            if (obj.elem.checked) {
                commonenable(this.value, 'False');
            } else {
                commonenable(this.value, 'true');
            }

        });
        tableIns.on('checkbox(tableFilter)', function (obj) {
            var checkStatus = tableIns.checkStatus('dataTableId');
            var dataList = checkStatus.data;
            if (dataList != null && dataList.length > 0) {

                for (var i = 0; i < dataList.length; i++) {
                    ids += dataList[i].id + ",";
                }
            }
        });

        function deleteId(ids) {
            if (ids != "") {
                $.ajax({
                    url: "/delete/data",
                    type: 'post',
                    data: {"table": table, "ids": ids},
                    async: false,
                    dataType: "json",
                    success: function (arg) {
                        if (arg) {
                            layer.msg(arg.message);
                            search();
                        } else {
                            layer.msg(arg.message);
                        }
                    }
                });
            }
        }

        $("#multiDelete").click(function () {
            deleteId(ids)
        });

        tableIns.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');
            } else if (obj.event === 'del') {
                if (data.has_deleted == 1) {
                    layer.msg('已删除，不可进行该操作!', {icon: 1, time: 1000});
                    return;
                }
                layer.confirm('真的删除行么', function (index) {
                    deleteId(data.id)
                    layer.close(index);
                });
            } else if (obj.event === 'edit') {
                if (data.has_deleted == 1) {
                    layer.msg('已删除，不可进行该操作!', {icon: 1, time: 1000});
                    return;
                }
                layer_show("轮播图修改", "/application/moduleSave?id=" + data.id, "550", "650");
                parent.search();
            } else if (obj.event === 'save') {
                $.ajax({
                    url: "/application/sortSave",    //请求的url地址
                    dataType: "json",   //返回格式为json
                    async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                    data: {table: table, id: data.id, sort: data.sort},    //参数值,键值对
                    type: "post",   //请求方式
                    beforeSend: function () {
                        //请求前的处理
                    },
                    success: function (req) {
                        //请求成功时处理
                        if (req.success) {
                            showmsg(req.message);
                            search();
                        } else {
                            layer.msg(req.message)
                        }
                    },
                    complete: function () {
                        //请求完成的处理
                    },
                    error: function () {
                        //请求出错处理
                        layer.msg("请重试！若在失败请联系管理员")
                    }
                });
            }
        });
    });

    function search() {
        var star = $("#star").val();
        var end = $("#end").val();
        var sdkId = $("#sdkId").val();
        tableIns.reload('dataTableId', {
            where: {star: star,end:end,sdkId:sdkId},
            page: {
                curr: 1
            }
        });
    }


    function showmsg(msg) {
        layer.msg(msg)
    }

    function commonenable(id, status) {
        $.ajax({
            url: "/common/enablebyid",
            type: 'post',
            data: {"table": table, "id": id, "status": status},
            async: false,
            dataType: "json",
            success: function (arg) {
                if (arg) {
                    layer.msg(arg.message);
                    search();
                } else {
                    layer.msg(arg.message);
                }
            }
        });
    }

    function addBanner() {
        layer_show("轮播图新增", "/application/moduleSave", "550", "650");
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
